capture log close
clear all
set maxvar 10000
set more off
pause off
# delimit;

/*
Figure B3
*/

local data "" ;
local output "" ;

local title_n_crime2char_18_38 		"Any criminal charge, ages 18-38" ;
local title_n_crime2chart_18_38 	"Number of criminal charges, ages 18-38" ;
local title_n_crime2genr_18_38 		"Any income-generating charge, ages 18-38" ;
local title_n_crime2genrt_18_38 	"Number of income-generating charges, ages 18-38" ;
local title_n_crime2nogn_18_38 		"Any NON-income-generating charge, ages 18-38" ;
local title_n_crime2nognt_18_38 	"Number of NON-income-generating charges, ages 18-38" ;
local title_n_crime2ahinc_18_38		"Annual likelihood of incarceration, ages 18-38" ;


foreach var in
	n_crime2chart_18_38 n_crime2genrt_18_38 n_crime2nognt_18_38 n_crime2ahinc_18_38 
	{ ;
	
	use "prworaexact_robust_`var'_poly1allcov_rd_all.dta", clear ;
	
	rename _b_n_post b ;
	rename _se_n_post se ;
	keep bwidth b se ;	
	gen hi95 = b + 1.96*se ;
	gen lo95 = b - 1.96*se ;
	
	twoway 

		(rcap 		hi95 lo95 bwidth if bwidth >= 50, color(blue*.25) )
		(connected 	b		  bwidth if bwidth >= 50, color(blue) msymbol(o) msize(small))
		
		, 
		legend(off)
		title("`title_`var''", size(medsmall))
		xsc(r(0 400)) xtitle("Bandwidth (days)", size(medsmall))
		xlab(0(50)400)
		graphregion(color(white))
		bgcolor(white)
		ytitle("RD estimate")
		ylabel(,nogrid angle(0) axis(1))
		plotregion(margin(0 2 2 2))  
		yline(0, lcolor(gray))
		;
		graph export "`output'/figB3_`var'.png", width(1000) height(750) replace ;
	
} ;
